<?php 
//PHP Ping by fvox 
 
function ping($host){ 
    $suck = socket_create(AF_INET, SOCK_RAW, getprotobyname("ICMP")); 
    $stime = array_sum(explode(" ", microtime())); 
    socket_sendto($suck, "\x08\x00\x19\x2f\x00\x00\x00\x00ping", 12, 0x4, $host, 4242); 
    socket_read($suck, 512); 
    $etime = array_sum(explode(" ", microtime())); 
    socket_close($suck); 
    $time = $etime - $stime; 
 
    if(!is_float($time)) 
        return false; 
    else 
        return substr($time, 3, 2); 
} 
 
echo ping("www.google.com")."ms";
 

?> 